package com.example.mybatis;

import org.springframework.beans.factory.FactoryBean;

import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @Date 2022/1/19
 * @Created by Jonathan
 */
public class FactoryBeanDemo implements FactoryBean<UserDAO> {
	@Override
	@SuppressWarnings({"rawtypes", "unchecked"})
	public UserDAO getObject() throws Exception {
		UserDAO o = (UserDAO) Proxy.newProxyInstance(FactoryBeanDemo.class.getClassLoader(), new Class[]{UserDAO.class}, (Object proxy, Method method, Object[] args) -> {
			System.out.println("这是DAO接口的实现类.");
			return null;
		});
		return o;
	}

	@Override
	public Class<?> getObjectType() {
		return UserDAO.class;
	}
}
